<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "address".
 *
 * @property string $addressId
 * @property string $firstname
 * @property string $lastname
 * @property string $company
 * @property string $address
 * @property string $postcode
 * @property string $email
 * @property integer $telephone
 * @property integer $userId
 * @property string $createTime
 *
 * @property ShopOrder[] $shopOrders
 */
class Address extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'address';
    }
    
    public static function getCTableName()
    {
        return '地址';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['address', 'telephone', 'userId'], 'required'],
            [['address'], 'string'],
            [['telephone', 'userId'], 'integer'],
            [['createTime'], 'safe'],
            [['firstname', 'lastname'], 'string', 'max' => 32],
            [['company'], 'string', 'max' => 36],
            [['postcode'], 'string', 'max' => 6],
            [['email'], 'string', 'max' => 100],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'addressId' => '地址ID',
            'firstname' => '姓',
            'lastname' => '名',
            'company' => '公司名',
            'address' => '详细地址',
            'postcode' => '邮编',
            'email' => '邮箱',
            'telephone' => '手机号',
            'userId' => '用户',
            'createTime' => '创建时间',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getShopOrders()
    {
        return $this->hasMany(ShopOrder::className(), ['addressId' => 'addressId']);
    }
}
